How to: Create a macro using the Visual Basic language.
Solution:
Insert a module macro sheet. Start the macro with 'SUB' followed by the macro name, type the appropriate Visual Basic code, and end the macro with 'END SUB'.
1) Select the 'Insert' menu and select 'Macro'. (A submenu appears.)
2) Select 'Module' from the submenu. (Excel displays a new sheet to hold the macro.)
3) Type SUB, a space, and the macro name.
EXAMPLE: SUB CostCaculator
4) (Optional) Type arguments, if any, immediately after the name.
NOTE: Enclose the arguments within parentheses, separating arguments with a comma.
5) Press ENTER.
6) Type the appropriate Visual Basic code.
7) Type END SUB in a new line when the code is complete.
8) Press ENTER.